package com.sky.controller;

import com.sky.service.UmsMemberLevelService;
import com.sky.utils.PageUtils;
import com.sky.utils.R;
import com.sky.vo.param.UmsMemberLevelVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/umsMemberLevel")
public class UmsMemberLevelController {

    @Resource
    private UmsMemberLevelService umsMemberLevelService;

    @GetMapping("/page")
    public R page(UmsMemberLevelVO vo) {
        PageUtils page = umsMemberLevelService.pageQuery(vo);
        return R.ok(page);
    }

    @PostMapping("/addUmsMemberLevel")
    public R addUmsMemberLevel(@RequestBody UmsMemberLevelVO vo) {
        boolean add = umsMemberLevelService.addUmsMemberLevel(vo);
        return add ? R.ok() : R.error();
    }

    @PostMapping("/updateUmsMemberLevel")
    public R updateUmsMemberLevel(@RequestBody UmsMemberLevelVO vo) {
        boolean update = umsMemberLevelService.updateUmsMemberLevel(vo);
        return update ? R.ok() : R.error();
    }

    @DeleteMapping("/deleteUmsMemberLevel")
    public R deleteUmsMemberLevel(@RequestBody Long[] ids) {
        boolean delete = umsMemberLevelService.deleteUmsMemberLevel(ids);
        return delete ? R.ok() : R.error();
    }

    @GetMapping("/getUmsMemberLevelById/{id}")
    public R getUmsMemberLevelById(@PathVariable("id") Long id) {
        UmsMemberLevelVO umsMemberLevelVO = umsMemberLevelService.getUmsMemberLevelById(id);
        return R.ok(umsMemberLevelVO);
    }
}
